# 目录描述
set(PROJ_ROOT_DIR ${CMAKE_SOURCE_DIR}) # 项目根目录
set(PROJ_APPLICATIONS_DIR ${PROJ_ROOT_DIR}/Applications) # App目录
set(PROJ_BUILD_DIR ${PROJ_ROOT_DIR}/build) # 构建目录
set(PROJ_CMAKE_DIR ${PROJ_ROOT_DIR}/CMake) # CMake项目目录
set(PROJ_DRIVERS_DIR ${PROJ_ROOT_DIR}/Drivers) # 驱动库目录
set(PROJ_MIDDLEWARES_DIR ${PROJ_ROOT_DIR}/Middlewares) # 第三方件源码目录
set(PROJ_SYSTEM_DIR ${PROJ_ROOT_DIR}/System) # MCU配置与bsp
set(PROJ_USER_DIR ${PROJ_ROOT_DIR}/User) # User目录

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJ_CMAKE_DIR}/bin) # 可执行文件输出目录
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJ_CMAKE_DIR}/lib/dynamic) # 动态库输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJ_CMAKE_DIR}/lib/static) # 静态库输出目录

# 基本配置(必需放在 project 前面)
include(${PROJ_CMAKE_DIR}/cmake/target-def.cmake) # MCU 信息设置
include(${PROJ_CMAKE_DIR}/cmake/arm-toolkit.cmake) # 编译器设置

# 项目描述
cmake_minimum_required(VERSION 3.22)
project(imu C CXX ASM)
set(VERSION_MAJOR 0 CACHE STRING "Project major version number.")
set(VERSION_MINOR 1 CACHE STRING "Project minor version number.")
set(VERSION_PATCH 0 CACHE STRING "Project patch version number.")
set(ELF_TARGET ${PROJECT_NAME}.elf) # elf文件名

# 编译模式
set(CMAKE_BUILD_TYPE Debug)
if(CMAKE_BUILD_TYPE MATCHES Debug)
  message(STATUS "Build type: Debug")
elseif(CMAKE_BUILD_TYPE MATCHES Release)
  message(STATUS "Build type: Release")
endif()

# 其它设置
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # 生成编译数据库

# 添加子目录
add_subdirectory(${PROJ_CMAKE_DIR}/user) # 构建 Executable